package com.superman.thread.func;

import cn.hutool.core.exceptions.ExceptionUtil;

import java.io.Serializable;

/**
 * 有参+有返回值 函数对象
 * take nothing return nothing
 * take having return having
 *
 * @Author: superman
 * @Date: 2024/5/22 14:40
 */
@FunctionalInterface
public interface TakeNothingReturnNothing extends Serializable {
    /**
     * 执行函数
     *
     * @throws Exception 自定义异常
     */
    void call() throws Exception;

    /**
     * 执行函数，异常包装为RuntimeException
     */
    default void callWithRuntimeException() {
        try {
            call();
        } catch (Exception e) {
            throw ExceptionUtil.wrapRuntime(e);
        }
    }
}
